package ru.nsu.fit.client.core.response;

public class KernelResponse {
    private int id = 0;
    private long userSessionId;
    private boolean changeUserSessionId = false;
    private int errorCode = -1;
    private String errorText = null;
    private IResponseData data = null;

    public KernelResponse(boolean success)
    {
        if (!success)
        {
            errorText = "Unknown error";
        }
        setSuccessful(success);
    }

    public int getId() {
        return id;
    }

    public void setId(int id) {
        this.id = id;
    }

    public boolean isSuccessful() {
        return errorCode == 0;
    }

    public void setSuccessful(boolean successful) {
        if (successful)
        {
            errorCode = 0;
        }
        else
        {
            errorCode = -1;
        }
    }

    public String getErrorText() {
        return errorText;
    }

    public void setErrorText(String errorText) {
        this.errorText = errorText;
    }

    public long getUserSessionId() {
        return userSessionId;
    }

    public void setUserSessionId(long userSessionId) {
        this.userSessionId = userSessionId;
    }

    public boolean isChangeUserSessionId() {
        return changeUserSessionId;
    }

    public void setChangeUserSessionId(boolean changeUserSessionId) {
        this.changeUserSessionId = changeUserSessionId;
    }

    public int getErrorCode() {
        return errorCode;
    }

    public void setErrorCode(int errorCode) {
        this.errorCode = errorCode;
    }

    public IResponseData getData() {
        return data;
    }

    public void setData(IResponseData data) {
        this.data = data;
    }
}
